package com.shensi.appCollect.task;

import com.shensi.appCollect.service.CouponService;
import com.shensi.appCollect.service.WxMessageTemplateService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@Slf4j
public class WxMessageScheduledTask {

    @Autowired
    private WxMessageTemplateService wxMessageTemplateService;
    @Autowired
    private CouponService couponService;

    // 微信模板消息推送(间隔10分钟执行一次) 600000ms=600s
    @XxlJob("wxMessageTemplatePush")
    public void wxMessageTemplatePush() {
        log.info("========================[wxMessageTemplatePush]微信模板消息推送定时任务-开始执行==========================");
        //wxMessageTemplateService.WxMessageTemplatePushForRedis();
        wxMessageTemplateService.batchSendOilPriceAdjustWxTemplateMessageFromRedis();
        log.info("========================微信模板消息推送定时任务-执行结束==========================");
    }

    @XxlJob("batchPushWxGzhCouponExpire")
    public void batchPushWxGzhCouponExpire() {
        log.info("========================优惠券到期微信公众号推送定时任务-开始执行==========================");
        couponService.batchPushWxGzhCouponExpire();
        log.info("========================优惠券到期微信公众号推送定时任务-执行结束==========================");
    }
}
